package com.guobox.movies.view.decoration;

import android.graphics.Canvas;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by xxl on 16/7/28.
 */
public class MovieListItemDecoration extends RecyclerView.ItemDecoration {
    private static final String TAG = "Decoration";

    public MovieListItemDecoration() {
        super();
    }


    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        int movieItemPos = parent.getChildAdapterPosition(view) - 1;
        if (movieItemPos >= 0) {
            if (movieItemPos % 5 == 0 || movieItemPos % 5 == 1) {
                outRect.left = 15;
            } else if (movieItemPos % 5 == 3 || movieItemPos % 5 == 4) {
                outRect.right = 15;
            }
        }

    }
    @Override
    public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
        super.onDraw(c, parent, state);
    }
}
